import esriLoader from 'esri-loader'
import mapconfig from '../config/mapconfigshare'

const pathRegex = new RegExp(/\/[^\/]+$/);
const locationPath = location.pathname.replace(pathRegex, '');
const dojoConfig = {
  async: true,
  packages: [{
    //  location: locationPath + '/arcgis/utils',
    // location: "http://powergis.smi.sh.cegn.cn/xuhuiProject/map" + '/arcgis/utils',
    location: "http://31.0.37.225:8080/map/arcgis/utils",
    name: 'utils'
  }, {
    // location: locationPath + '/arcgis/extensions',
    // location: "http://powergis.smi.sh.cegn.cn/xuhuiProject/map" + '/arcgis/extensions',Y
    location: "http://31.0.37.225:8080/map/arcgis/extensions",
    name: "extensions"
  }],
  deps: ['@dojo/framework/shim/main'],
  has: {
    'esri-promise-compatibility': 1,
    'esri-featurelayer-webgl': 1
  }
}

function configEsriLoader() {
  esriLoader.utils.Promise = Promise
}

export default function load(modules) {
  configEsriLoader()
  return esriLoader.loadModules(modules, {
    dojoConfig,
    //version: '4.13',
    url: mapconfig.jsApiUrl
  })
}
